<?php
class ui_index_recommend extends ui {
	/**
	 * @param object $S
	 * @param array $param = array (
	 *		page
	 *	)
	 */
	public function __construct($S, $param) {
		parent::__construct();
		
		$limit = 0;			// 不限制数量
		$param['page'] = (isset($param['page'])) ? intval($param['page']) : 1;

		$data_recommend_article = new data_recommend_article();
		$recommend = $data_recommend_article->ls($this->uid, 'unread', 0, $param['page'], $limit);
		
		// 判断第一页和最后一页
		$is_last = 0;
		if ($param['page'] > 1 and empty($recommend)) {					// 不是第一页，而且没有数据了，那么一定就是最后一页了
			$is_last = 1;
			$param['page'] = $param['page'] - 1;
			$recommend = $data_recommend_article->ls($this->uid, 'unread', 0, $param['page'], $limit);
		}
		
		$S->assign('is_last',		$is_last);
		$S->assign('page', 		$param['page']);
		$S->assign('recommend',	$recommend);
	}
}
?>